import random
getTicket = random.sample(range(1,33),8)
str = input("请输入8位数字，用逗号分隔：")
if len(str)>8 & len(str) <8:
    print("输入的数字范围不是8位")
else:
    result=str.split(",")
    myTicket = list(map(int,result))
    print("中奖号码是{}".format(getTicket))
    print("您购买的号码是{}".format(myTicket))
    print("你选中的号码有:{}".format(list(set(getTicket).intersection(set(myTicket)))))

first,second,third,fourth,sorry = 0,0,0,0,0
luckTicket = [12,22,31,5,8,27,1,19]
for i in range(1000):
    myTicket = random.sample(range(1,33),8)
    if len(list(set(luckTicket).intersection(set(myTicket))))==5:
        fourth = fourth + 1
        print("开奖号码：{} -- 我的号码:{} -- 买中的号码:{}".format(luckTicket,myTicket,list(set(luckTicket).intersection(set(myTicket)))))
    elif len(list(set(luckTicket).intersection(set(myTicket))))==6:
        third = third + 1
        print("开奖号码：{} -- 我的号码:{} -- 买中的号码:{}".format(luckTicket,myTicket,list(set(luckTicket).intersection(set(myTicket)))))
    elif len(list(set(luckTicket).intersection(set(myTicket))))==7:
        second = second + 1
        print("开奖号码：{} -- 我的号码:{} -- 买中的号码:{}".format(luckTicket, myTicket,list(set(luckTicket).intersection(set(myTicket)))))
    elif len(list(set(luckTicket).intersection(set(myTicket))))==8:
        first = first + 1
        print("开奖号码：{} -- 我的号码:{} -- 买中的号码:{}".format(luckTicket,myTicket,list(set(luckTicket).intersection(set(myTicket)))))
    else:
        sorry = sorry+1
print("一等奖:{}次".format(first))
print("二等奖:{}次".format(second))
print("三等奖:{}次".format(third))
print("四等奖:{}次".format(fourth))
print("未中奖:{}次".format(sorry))


